//
//  HMFoundProposalCell.swift
//  HealthMonitoring
//
//  Created by YTYanK on 14/11/2018.
//  Copyright © 2018 YTYanK. All rights reserved.
//

import UIKit
import SwiftyJSON

class HMFoundProposalCell: HMTableViewCell {
    public var cellHeight: CGFloat = 0.0
    

    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    class func cell(json: JSON, tableView: UITableView, cellForRowAt indexPath: IndexPath) -> HMFoundProposalCell? {
       let identifier = "HMFoundProposalCell"
        var cell: HMFoundProposalCell? = tableView.dequeueReusableCell(withIdentifier: identifier) as? HMFoundProposalCell
        
        if cell == nil {
            cell = HMFoundProposalCell.init(style: .default, reuseIdentifier: identifier)
        }
        cell?.setupViews(json: json, tableView: tableView, view: (cell?.contentView)!, indexPath: indexPath)
        cell?.selectionStyle = UITableViewCellSelectionStyle.none
//        cell?.backgroundColor = .red
       return cell
    }
    
    
    func setupViews(json: JSON, tableView: UITableView, view: UIView, indexPath: IndexPath) {
        
        let addIcon = UIImageView()
         addIcon.image = UIImage.init(named: "add")
        let text = UILabel()
        text.text = "添加新的药物建议"
        text.textColor = configure.shareConfigure.HMColor4
        view.addSubview(addIcon)
        view.addSubview(text)
        
        
        
//        addIcon.centerXAlign(view: view)
        addIcon.centerXAlign(view: self, predicate: "0")
        addIcon.centerYAlign(view: self, predicate: "-10")
        addIcon.widthConstrain(predicate: "35")
        addIcon.heightConstrain(predicate: "35")
        
        text.topVertically(view: addIcon)
        text.centerXAlign(view: view)
        
//        self.cellHeight = 44.0
    }
    
}
